<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2023/5/4
 * Time: 15:20
 */

namespace Database\Factories;
use App\Models\Employee;
use App\Models\JobType;
use App\Models\Rbac\User;
use Illuminate\Database\Eloquent\Factories\Factory;



class EmployeeFactory extends Factory
{

    /**
     * 虚拟员工添加方式：
     * php artisan tinker
     * \App\Models\Employee::factory()->count(14)->create();
     */

    protected $model = Employee::class;
    public function definition()
    {
        $job_type = JobType::where('is_del',2)->pluck('id')->toArray();

        return [
            'user_id'=>function(){
                return self::factoryForModel(User::class)->create()->id;
            },
            'employee_name'=>fake()->name,
            'phone'=>fake()->phoneNumber,
            'is_del'=>2,
            'address'=>fake()->address,
            'job_type_id'=>fake()->randomElement($job_type),
            'id_card'=>'',
            'native_place'=>fake()->address,
            'emergency_contact'=>fake()->name,
            'emergency_contact_phone'=>fake()->phoneNumber,
            'card_number'=>'',
            'base_pay'=>5000,
            'hiredate'=>'2023-01-01 09:00:00',
            'submit_way'=>''
        ];
    }
}